package cn.iocoder.yudao.module.research.dal.mysql.alert;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.research.dal.dataobject.alert.AlertDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.research.controller.admin.alert.vo.*;

/**
 * 告警 Mapper
 *
 * @author cai
 */
@Mapper
public interface AlertMapper extends BaseMapperX<AlertDO> {

    default PageResult<AlertDO> selectPage(AlertPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<AlertDO>()
                .eqIfPresent(AlertDO::getXff, reqVO.getXff())
                .eqIfPresent(AlertDO::getUrl, reqVO.getUrl())
                .betweenIfPresent(AlertDO::getAlertTime, reqVO.getAlertTime())
                .likeIfPresent(AlertDO::getThreatName, reqVO.getThreatName())
                .eqIfPresent(AlertDO::getThreatLevel, reqVO.getThreatLevel())
                .eqIfPresent(AlertDO::getDirection, reqVO.getDirection())
                .eqIfPresent(AlertDO::getSourceIp, reqVO.getSourceIp())
                .betweenIfPresent(AlertDO::getSourceIpLong, reqVO.getSourceIpLong())
                .eqIfPresent(AlertDO::getDestIp, reqVO.getDestIp())
                .betweenIfPresent(AlertDO::getDestIpLong, reqVO.getDestIpLong())
                .eqIfPresent(AlertDO::getStatusCode, reqVO.getStatusCode())
                .eqIfPresent(AlertDO::getStatus, reqVO.getStatus())
                .eqIfPresent(AlertDO::getRemark, reqVO.getRemark())
                .betweenIfPresent(AlertDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(AlertDO::getSyslogId, reqVO.getSyslogId())
                .eqIfPresent(AlertDO::getAttackType, reqVO.getAttackType())
                .eqIfPresent(AlertDO::getSourcePort, reqVO.getSourcePort())
                .eqIfPresent(AlertDO::getDestPort, reqVO.getDestPort())
                .eqIfPresent(AlertDO::getAnalyzeStep, reqVO.getAnalyzeStep())
                .eqIfPresent(AlertDO::getAttackStatus, reqVO.getAttackStatus())
                .orderByDesc(AlertDO::getId));
    }

}